<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<button type="button" class="btn btn-primary set-btn">查询</button>
<input type="text" value="广东省" name="province"
class="form-control province" placeholder="请输入城市省份名称">
<input type="text" value="珠海市" name="city" class="form-control city" placeholder="请输入城市的名称">
<p>地区列表</p>
<ul class="list-group">
    <li class="list-group-item">
        斗门区
    </li>
</ul>
<script  src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<!-- //根据省份的名字来查询地区列表 -->
<!-- 查询参数:
pname:省份
cname:城市 -->
<!-- 1.查询按钮:绑定点击事件 -->
<script>
document.querySelector('.set-btn').addEventListener('click',()=>{
    // 获取省份和城市的名字
    // console.log("点击了")
    let pName=document.querySelector('.province').value
    let cName=document.querySelector('.city').value
    //基于axios的数据
    axios({
        url:'http://hmajax.itheima.net/api/area',
        params:{
            pname:pName,
            cname:cName
        }
    }).then(result=>{
        let list=result.data.list
        console.log(list)
        let theLi=list.map(areaName=>list).join('<br>')
        //console.log(theLi)
        document.querySelector('.list-group').innerHTML=theLi
    })
})
</script>
<body>
  
</body>
</html>